<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="baidu-site-verification" content="SCzNOI2Wq6" />
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>
        daozhuang
    </title>
    
<link rel="stylesheet" href="/libs/highlight/styles/monokai-sublime.css">

    
<link rel="stylesheet" href="/libs/font-awesome/css/font-awesome.min.css">

    
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 4.2.1"></head>

<body id="bodyx">
    <div class="hd posts">
    <a href="/index.html"><i class="fa fa-reply replay-btn" aria-hidden="true"></i></a>
    <div class="post-title">
        <p>
            kubenetes
        </p>
        <hr>
    </div>
    <div class="post-content">
        <h1 id="kubenetes-安装"><a href="#kubenetes-安装" class="headerlink" title="kubenetes 安装"></a>kubenetes 安装</h1><h2 id="设置-阿里云镜像"><a href="#设置-阿里云镜像" class="headerlink" title="设置 阿里云镜像"></a>设置 阿里云镜像</h2><p>cat &lt;<EOF > /etc/yum.repos.d/kubernetes.repo<br>[kubernetes]<br>name=Kubernetes<br>baseurl=<a href="https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/" target="_blank" rel="noopener">https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/</a><br>enabled=1<br>gpgcheck=1<br>repo_gpgcheck=1<br>gpgkey=<a href="https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg" target="_blank" rel="noopener">https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg</a> <a href="https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg" target="_blank" rel="noopener">https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg</a><br>EOF</p>
<h2 id="安装-kubeadm、kubelet-和-kubectl"><a href="#安装-kubeadm、kubelet-和-kubectl" class="headerlink" title="安装 kubeadm、kubelet 和 kubectl"></a>安装 kubeadm、kubelet 和 kubectl</h2><p><a href="https://kubernetes.io/zh/docs/setup/production-environment/tools/kubeadm/install-kubeadm/" target="_blank" rel="noopener">https://kubernetes.io/zh/docs/setup/production-environment/tools/kubeadm/install-kubeadm/</a></p>
<h2 id="安装支持-kubenetes-的-docker"><a href="#安装支持-kubenetes-的-docker" class="headerlink" title="安装支持 kubenetes 的 docker"></a>安装支持 kubenetes 的 docker</h2><p><a href="https://kubernetes.io/zh/docs/setup/production-environment/container-runtimes/" target="_blank" rel="noopener">https://kubernetes.io/zh/docs/setup/production-environment/container-runtimes/</a></p>
<h2 id="初始化-kubenetes-主节点"><a href="#初始化-kubenetes-主节点" class="headerlink" title="初始化 kubenetes 主节点"></a>初始化 kubenetes 主节点</h2><p><a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/" target="_blank" rel="noopener">https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/</a></p>
<h2 id="可能会需要的步骤-一下是把-镜像推到-自己的-docker-仓库"><a href="#可能会需要的步骤-一下是把-镜像推到-自己的-docker-仓库" class="headerlink" title="可能会需要的步骤    一下是把  镜像推到 自己的  docker 仓库"></a>可能会需要的步骤    一下是把  镜像推到 自己的  docker 仓库</h2><p>01 <code>查看kubeadm使用的镜像</code><br>    kubeadm config images list</p>
<h1 id=""><a href="#" class="headerlink" title="===================================================================================="></a>====================================================================================</h1><p>k8s.gcr.io/kube-apiserver:v1.14.0<br>k8s.gcr.io/kube-controller-manager:v1.14.0<br>k8s.gcr.io/kube-scheduler:v1.14.0<br>k8s.gcr.io/kube-proxy:v1.14.0<br>k8s.gcr.io/pause:3.1<br>k8s.gcr.io/etcd:3.3.10<br>k8s.gcr.io/coredns:1.3.1</p>
<h1 id="-1"><a href="#-1" class="headerlink" title="===================================================================================="></a>====================================================================================</h1><p>02 <code>解决国外镜像不能访问的问题</code></p>
<h1 id="创建kubeadm-sh脚本，用于拉取镜像-打tag-删除原有镜像"><a href="#创建kubeadm-sh脚本，用于拉取镜像-打tag-删除原有镜像" class="headerlink" title="创建kubeadm.sh脚本，用于拉取镜像/打tag/删除原有镜像"></a>创建kubeadm.sh脚本，用于拉取镜像/打tag/删除原有镜像</h1><pre><code>vi kubeadm.sh</code></pre><h1 id="-2"><a href="#-2" class="headerlink" title="===================================================================================="></a>====================================================================================</h1><p>#!/bin/bash<br>set -e<br>KUBE_VERSION=v1.14.0<br>KUBE_PAUSE_VERSION=3.1<br>ETCD_VERSION=3.3.10<br>CORE_DNS_VERSION=1.3.1<br>GCR_URL=k8s.gcr.io<br>ALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/google_containers<br>images=(kube-proxy:${KUBE_VERSION}<br>kube-scheduler:${KUBE_VERSION}<br>kube-controller-manager:${KUBE_VERSION}<br>kube-apiserver:${KUBE_VERSION}<br>pause:${KUBE_PAUSE_VERSION}<br>etcd:${ETCD_VERSION}<br>coredns:${CORE_DNS_VERSION})<br>for imageName in ${images[@]} ; do<br>    docker pull $ALIYUN_URL/$imageName<br>    docker tag  $ALIYUN_URL/$imageName $GCR_URL/$imageName<br>    docker rmi $ALIYUN_URL/$imageName<br>done</p>
<h1 id="-3"><a href="#-3" class="headerlink" title="===================================================================================="></a>====================================================================================</h1><p>03 <code>运行脚本和查看镜像</code><br>    sh ./kubeadm.sh 【运行脚本】<br>    docker images 【查看镜像】<br>04 <code>将这些镜像推送到自己的阿里云仓库</code>【可选，根据自己实际的情况】<br>    docker login –username=happyeveryday2019 registry.cn-hangzhou.aliyuncs.com 【登录自己的阿里云仓库，master节点执行即可】<br>    密码：<strong>**</strong><br>    vi kubeadm-push-aliyun.sh</p>
<h1 id="-4"><a href="#-4" class="headerlink" title="===================================================================================="></a>====================================================================================</h1><p>#!/bin/bash<br>set -e<br>KUBE_VERSION=v1.14.0<br>KUBE_PAUSE_VERSION=3.1<br>ETCD_VERSION=3.3.10<br>CORE_DNS_VERSION=1.3.1<br>GCR_URL=k8s.gcr.io<br>ALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/841863085<br>images=(kube-proxy:${KUBE_VERSION}<br>kube-scheduler:${KUBE_VERSION}<br>kube-controller-manager:${KUBE_VERSION}<br>kube-apiserver:${KUBE_VERSION}<br>pause:${KUBE_PAUSE_VERSION}<br>etcd:${ETCD_VERSION}<br>coredns:${CORE_DNS_VERSION})<br>for imageName in ${images[@]} ; do<br>    docker tag $GCR_URL/$imageName $ALIYUN_URL/$imageName<br>    docker push $ALIYUN_URL/$imageName<br>    docker rmi $ALIYUN_URL/$imageName<br>done</p>
<h1 id="-5"><a href="#-5" class="headerlink" title="===================================================================================="></a>====================================================================================</h1><p>06 <code>运行脚本</code><br>    sh ./kubeadm-push-aliyun.sh</p>

    </div>

    
        <hr class="fhr">
        <div id="vcomments"></div>
    
</div>
    <div class="footer" id="footer">
    <p>Copyright © 2020 <a class="flink" href="https://hexo.io" target="_blank" rel="noopener">Hexo</a>-<a class="flink" href="https://github.com/sanjinhub/hexo-theme-geek" target="_blank" rel="noopener">Geek</a>.
        <label class="el-switch el-switch-green el-switch-sm" style="vertical-align: sub;">
            <input type="checkbox" name="switch" id="update_style">
            <span class="el-switch-style"></span>
        </label>
<!--         <script type="text/javascript">
        var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");
        document.write(unescape("%3Cspan id='cnzz_stat_icon_1278548644'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "v1.cnzz.com/stat.php%3Fid%3D1278548644%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));
        </script> -->
    </p>
</div>
<input type="hidden" id="web_style" value="black">
<input type="hidden" id="valine_appid" value="c994h5wXLa8fSMa424BTyVhs-gzGzoHsz">
<input type="hidden" id="valine_appKey" value="4tFbwCi4sYo3yRFgiNFpQd4N">

<script src="/libs/jquery.min.js"></script>


<script src="/libs/highlight/highlight.pack.js"></script>

<script src='//cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>

<script src="/js/js.js"></script>

<style type="text/css">
.v * {
    color: #698fca;
}

.v .vlist .vcard .vhead .vsys {
    color: #3a3e4a;
}

.v .vlist .vcard .vh .vmeta .vat {
    color: #638fd5;
}

.v .vlist .vcard .vhead .vnick {
    color: #6ba1ff;
}

.v a {
    color: #8696b1;
}

.v .vlist .vcard .vhead .vnick:hover {
    color: #669bfc;
}
</style>
</body>

</html>